<% layout('/layouts/default.html', {title: '游泳馆商品管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(natatoriumGoods.isNewRecord ? '新增游泳馆商品' : '编辑游泳馆商品')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${natatoriumGoods}" action="${ctx}/natatoriumgoods/natatoriumGoods/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>
				<#form:hidden path="natatoriumInfoId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('商品名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="name" maxlength="500" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('商品类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:radio path="goodsType" dictType="goods_type" class="form-control required" defaultValue="1" autocomplete="off" />							
							</div>
						</div>
					</div>
				</div>
				<div class="row" id="course">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								${text('课程开始时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="courseStartTime" readonly="true" maxlength="20" class="form-control Wdate"
									dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								${text('课程结束时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="courseEndTime" readonly="true" maxlength="20" class="form-control Wdate"
									dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
							</div>
						</div>
					</div>		
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								${text('课程人数')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="courseNumber" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>												
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('原价')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="originalPrice" class="form-control required number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('价格')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="price" class="form-control required number"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('使用截至时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="useFinishTime" readonly="true" maxlength="20" class="form-control Wdate required"
									dataFormat="date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
							</div>
						</div>
					</div>				
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('商品状态')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="goodsStatus" dictType="goods_status" blankOption="true" class="form-control required digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('库存数量')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="number" maxlength="20" class="form-control digits"/>
							</div>
						</div>
					</div>					
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('商品内容')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="content" rows="4" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2"><span class="required ">*</span>${text('商品图片')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${natatoriumGoods.id}" bizType="natatoriumGoods_image"
									uploadType="image" class="required" readonly="false" maxUploadNum="3"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('natatoriumgoods:natatoriumGoods:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$(document).ready(function() {
	$('#course').hide();
	
	$("input[name='goodsType']").on('ifChecked', function(event) {
		if ($(this).val() == '2') {
			$('#course').show();
			if(typeof window.webuploaderRefresh == 'function'){
				window.webuploaderRefresh();
			}
		} else {
			$('#course').hide();
			if(typeof window.webuploaderRefresh == 'function'){
				window.webuploaderRefresh();
			}
		}
	})
})
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>